package com.station.administrators.service.impl;

import com.station.administrators.dao.PlatformActivityDao;
import com.open.capacity.common.model.ActivityModel;
import com.station.administrators.service.PlatformActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YangGang
 * @Description: TODO
 * @date 2021/6/25/9:48
 */
@Service
public class PlatformActivityServiceImpl implements PlatformActivityService {
    @Autowired
    private PlatformActivityDao platformActivityDao;

    @Override
    public void add(ActivityModel activity) {
        if(activity.getActiid()!=null){
            platformActivityDao.update(activity);
        }else {
            platformActivityDao.add(activity);
        }

    }

    @Override
    public void update(ActivityModel activity) {
        platformActivityDao.update(activity);
    }

    @Override
    public void delete(Long id) {
        platformActivityDao.delete(id);
    }

    @Override
    public ActivityModel findById(Long id) {
        return  platformActivityDao.findById(id);
    }

    @Override
    public List<ActivityModel> findAll(ActivityModel activity) {
        Integer page = activity.getPage();
        Integer limit = activity.getLimit();
        page=(page-1)*limit;
        activity.setPage(page);
        return platformActivityDao.findAll(activity);
    }

    @Override
    public Integer getCount(ActivityModel activity) {
        return platformActivityDao.getCount(activity);
    }
}
